package NIO.Buffer缓冲器;

import java.nio.CharBuffer;

/**
 * @author 陈鹏
 */
public class Example18 {
    public static void main(String[] args) {
        CharBuffer charBuffer=CharBuffer.allocate(6);
        System.out.println("容量："+charBuffer.capacity());
        System.out.println("界限值："+charBuffer.limit());
        System.out.println("初始位置："+charBuffer.position());
//        向charBuffer对象中放入3个元素
        charBuffer.put('x');
        charBuffer.put('y');
        charBuffer.put('z');
        System.out.println("加入元素后的界限值："+charBuffer.limit());
        System.out.println("加入元素后的位置"+charBuffer.position());

        charBuffer.flip();
        System.out.println("执行filp()后的界限值："+charBuffer.limit());
        System.out.println("执行filp()后的位置"+charBuffer.position());


    }
}
